import vix from '@bairong/vix'
import { HELIOS_PREFIX } from './urls'

const { request } = vix

// 获取字段模板列表
export function getFieldListApi(data: object) {
  return request({
    url: `${HELIOS_PREFIX}/variable/template/list`,
    method: 'post',
    data
  })
}

// 获取字段模板信息
export function getFieldDetailApi(data: object) {
  return request({
    url: `${HELIOS_PREFIX}/variable/template/getVariableById`,
    method: 'post',
    data
  })
}

// 获取所有字段
export function getAllFieldsApi(data: object) {
  return request({
    url: `${HELIOS_PREFIX}/variable/template/systemVariable`,
    method: 'post',
    data
  })
}

// 获取所有字段
export function getTypeFieldsApi(data: object) {
  return request({
    url: `${HELIOS_PREFIX}/variable/template/getVariableByType`,
    method: 'post',
    data
  })
}

// 验证模板重名
export function checkNameExistsApi(data: object) {
  return request({
    url: `${HELIOS_PREFIX}/variable/template/getVariableByName`,
    method: 'post',
    data
  })
}

// 新建字段模板
export function addFieldApi(data: object) {
  return request({
    url: `${HELIOS_PREFIX}/variable/template/save`,
    method: 'post',
    data
  })
}

// 编辑字段模板
export function updateFieldApi(data: object) {
  return request({
    url: `${HELIOS_PREFIX}/variable/template/update`,
    method: 'post',
    data
  })
}

// 更改模板状态
export function changeStatusApi(data: object) {
  return request({
    url: `${HELIOS_PREFIX}/variable/template/forbidden`,
    method: 'post',
    data
  })
}

// 删除模板
export function deleteFieldApi(data: object) {
  return request({
    url: `${HELIOS_PREFIX}/variable/template/delete`,
    method: 'post',
    data
  })
}
